<?php
/**
 * Created by PhpStorm.
 * User: JS
 * Date: 2019/2/18
 * Time: 14:11
 */

namespace Refine\Service;


use Psr\Log\LoggerInterface;
use Psr\SimpleCache\CacheInterface;

class CacheWithLogService
{
    /**
     * @var CacheInterface
     */
    protected $cache;
    /**
     * @var LoggerInterface
     */
    protected $logger;

    public function __construct($options)
    {
        $this->cache = $options['cache'];
        $this->logger = $options['logger'];
    }


    /**
     *
     */
    public function get($key, $default = null)
    {
        $this->logger->info('cache get key:'.$key);
        return  $this->cache->get($key,$default);
    }

    /**
     *
     */
    public function set($key, $value, $ttl = null)
    {
        $this->logger->info('cache set key:'.$key.' value:'.$value);
        return $this->cache->set($key,$value);
    }


    public function has($key)
    {
       return  $this->cache->has($key);
    }
}